﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using RollcallClient.Localhost;
using System.IO;
using System.Threading;
using System.Diagnostics;

namespace RollCallClient
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        /// 
        private static Mutex _AppMutex = new Mutex(false, "RollCall");

        [STAThread]
        static void Main()
        {
            if(!(File.Exists((Environment.SpecialFolder.Personal) + "\\RollCallClient")))
            {
                Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\RollCallClient");
            }
            if (Program._AppMutex.WaitOne(1, false))
            {
                Application.EnableVisualStyles();
                //Application.SetCompatibleTextRenderingDefault(false);
                RollcallMain roll = RollcallMain.GetRollcalMainObject();
                ThreadStart StarThread = new ThreadStart(roll.ReCheckAttend);
                Thread checkThread = new Thread(StarThread);
                if (!roll.GetCheckSuccess())
                {
                    checkThread.Start();
                }
                Application.Run();
                roll = null;
            }
            Application.Exit();
        }
    }
}
